/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.ServerSocket;

/**
 *
 * @author Leonardo Lino Nº45340
 * @author Diogo Pires Nº40351
 */
public class ConfigGeral {

    public static final String CG_SERVER_APP_IP = "127.0.0.1";
    public static final int CG_SERVER_APP_PORT = 2321;
    public static final String CG_SERVER_APP_NAME = "AppServer";

    public static final String CG_SERVER_DB_IP = "127.0.0.1";
    public static final int CG_SERVER_DB_PORT = 3333;
    public static final String CG_SERVER_DB_NAME = "dbServer";
    
     public static final String CG_ZOOKEEP_IP = "127.0.0.1";
    public static final int CG_ZOOKEEP_PORT = 2181;
    public static final String CG_ZOOKEEP_NAME = "ZooKeeper";

    public static final int COMPRA_OK = 0;
    public static final int COMPRA_EXPIRED = 1;
    public static final int COMPRA_NOTOK = 2;
    
    public static final int NUMEATROS = 15;
    
    public static final int NUM_ROWS = 26;
    public static final int NUM_COLS = 40;
    
    
    
     public static boolean availablePort(int port) {
    if (port < 1000 || port > 3000) {
        throw new IllegalArgumentException("Invalid start port: " + port);
    }

    ServerSocket ss = null;
    DatagramSocket ds = null;
    try {
        ss = new ServerSocket(port);
        ss.setReuseAddress(true);
        ds = new DatagramSocket(port);
        ds.setReuseAddress(true);
        return true;
    } catch (IOException e) {
    } finally {
        if (ds != null) {
            ds.close();
        }

        if (ss != null) {
            try {
                ss.close();
            } catch (IOException e) {
                /* should not be thrown */
            }
        }
    }

    return false;
}

}
